<?php
/**
 * 我的头像设置
 * 仲伟涛 2011-3
 */
class Resume_Page_Account extends Resume_Page_Abstract
{
    private $resumeDb;
    public function validate(ME_Request $input, ME_Response $output)
    {
        //获得登录的用户
        $input->jumpLogin   = true;
        $input->myLoginInfo = Libs_UcUser::checkLogin($input,$output);
        $output->uid        =
        $input->uid         = (int)$input->myLoginInfo['uid'];
        $input->userName    = $input->myLoginInfo['userName'];
        $output->myResumeConfig = ME_Config::get("MyResume");

        return true;
    }
    private function loadDb()
    {
        $this->resumeDb = Db_Resume::instance();
    }
    public function doAvatar(ME_Request $input, ME_Response $output){
        $output->uploadHTML = Libs_UcUser::uploadAvatar(array('uid'=>$input->uid) );

        $output->header = Resume_Plugin_Header::getHeader($input, $output);
        $output->footer = Resume_Plugin_Header::getFooter($input, $output);
        $output->setTemplate('Account/Avatar');
        
    }
    //修改密码的显示界面
    public function doShowChgPass(ME_Request $input, ME_Response $output){

        $output->header = Resume_Plugin_Header::getHeader($input, $output);
        $output->footer = Resume_Plugin_Header::getFooter($input, $output);
        $output->setTemplate('Account/ChgPass');
    }

    //修改密码
    public function doChgPass(ME_Request $input, ME_Response $output){

       $oldPass = $input->post("oldPassword");
       $newPass = $input->post("newPassword");

       $userInfo = Libs_UcUser::getUserInfo(array('nameOrId'=>$input->uid , 'flag'=>1));
       $userName = $userInfo['username'];
       $param = array(
           'username' => $userName,
           'oldpw'    => $oldPass,
           'newpw'    => $newPass,
       );
       //var_dump($param);exit;
       $rtn = Libs_UcUser::editUserInfo($param);
       //var_dump($rtn);exit;
       if(1 == $rtn['flag'] || 0 == $rtn['flag']){
            echo "<script>alert('密码修改成功！');</script>";
       }elseif(-1 == $rtn['flag']){
            echo "<script>alert('密码错误！');</script>";
       }else{
            echo "<script>alert('".$rtn['msg']."');</script>";
       }
       echo "<script>location.href='index.php?c=Account&a=ShowChgPass';</script>";
       exit;
    }



}

?>
